Responsive Web Design by Ethan Marcotte
Author:Ethan Marcotte [Marcotte, Ethan]
Language: eng
Format: epub, mobi
Tags: COMPUTERS / Web / Site Design
ISBN: 9780984442584
Publisher: A Book Apart
Published: 2011-06-13T16:00:00+00:00
FIG 4.9: By default, Mobile Safari renders web content at 980px wide—even though its display is 320px wide when held in portrait mode.
Using the viewport tag allows us to control the size of that canvas, and override that default behavior: we can dictate exactly how wide the browser’s viewport should be. For example, we could set our pages at a fixed width of 320px:
<meta name="viewport" content="width=320" />
Since being introduced by Apple, a number of mobile browser makers have adopted the viewport mechanic, creating something of a de facto standard. So let’s incorporate it into our soon-to-be responsive design. But instead of declaring a fixed pixel width, we’re going to take a more resolution-agnostic approach. In the head of our HTML, let’s drop in this meta element:
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
The initial-scale property sets the zoom level of the page to 1.0, or 100%, and helps ensure some consistency across small-screen, viewport-aware browsers. (For more information on how scaling works on different displays, I recommend Mozilla’s explanation: http://bkaprt.com/rwd/30/.)
But the important bit for us is the width=device-width setting, which makes the width of the browser’s viewport equal to the width of the device’s screen. So on an iPhone, for example, Mobile Safari’s layout area wouldn’t default to 980px anymore. Instead, it would be 320 pixels wide in portrait mode; in landscape, 480 pixels wide.
With this value in place, we can use max-width and min-width to look for resolution ranges below or above certain resolution thresholds, and conditionally load in CSS designed for those ranges. What’s more, this allows all query-aware browsers to take advantage of our media queries, making the design responsive for all users—whether they’re using phones, tablets, desktop computers, or laptops.
Okay, enough of my jabbering. Let’s see this in action.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Aircraft Design of WWII: A Sketchbook by Lockheed Aircraft Corporation(32136)
The Great Music City by Andrea Baker(30780)
Call Me by Your Name by André Aciman(19902)
The Art of Boudoir Photography: How to Create Stunning Photographs of Women by Christa Meola(18406)
The Secret History by Donna Tartt(18161)
Shoot Sexy by Ryan Armbrust(17556)
Plagued by Fire by Paul Hendrickson(17110)
Portrait Mastery in Black & White: Learn the Signature Style of a Legendary Photographer by Tim Kelly(16871)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16796)
Photographically Speaking: A Deeper Look at Creating Stronger Images (Eva Spring's Library) by David duChemin(16497)
Ready Player One by Cline Ernest(13987)
Pimp by Iceberg Slim(13779)
Bombshells: Glamour Girls of a Lifetime by Sullivan Steve(13684)
The Goal (Off-Campus #4) by Elle Kennedy(13196)
Art Nude Photography Explained: How to Photograph and Understand Great Art Nude Images by Simon Walden(12851)
Kathy Andrews Collection by Kathy Andrews(11323)
The Priory of the Orange Tree by Samantha Shannon(8611)
Thirteen Reasons Why by Jay Asher(8451)
The remains of the day by Kazuo Ishiguro(8394)
